# Contributor: rubicon <rubicon@mailo.com>
# Maintainer:
pkgname=jackline
pkgver=0.1.0
pkgrel=0
pkgdesc="Minimalistic and secure XMPP client written in OCaml"
url="https://github.com/hannesm/jackline"
# limited by riscv64: ocaml, ppc64le: ocaml-uucp and ocaml-erm_xmpp
arch="all !riscv64 !ppc64le"
license="BSD-2-Clause"
makedepends="
	ocaml-ppx_deriving-dev
	ocaml-erm_xmpp-dev
	ocaml-tls-dev
	ocaml-mirage-crypto-dev
	ocaml-x509-dev
	ocaml-domain-name-dev
	ocaml-lwt-dev
	ocaml-otr-dev
	ocaml-astring-dev
	ocaml-ptime-dev
	ocaml-notty-dev
	ocaml-sexplib-dev
	ocaml-hex-dev
	ocaml-uucp-dev
	ocaml-uuseg-dev
	ocaml-uutf-dev
	ocaml-dns-dev
	ocaml-cstruct-dev
	ocaml-base64-dev
	ocaml-happy-eyeballs-lwt-dev
	dune
	ocaml
	ocaml-ppx_sexp_conv-dev
	libev-dev
	gmp-dev
	"
source="$pkgname-$pkgver.tar.gz::https://github.com/hannesm/jackline/archive/refs/tags/v$pkgver.tar.gz
	use-built-in-uchar-lib.patch
	latest-notty-compat.patch
	"
_ocamldir=usr/lib/ocaml

# 32-bit archs
case "$CARCH" in
	arm*|x86) options="$options textrels" ;;
esac

prepare() {
	default_prepare
	sed -i "s/%%VERSION_NUM%%/$pkgver/" src/utils.ml
}

build() {
	dune build --release --verbose
}

check() {
	dune runtest --verbose
}

package() {
	dune install \
		--destdir="$pkgdir" \
		--docdir=/.omit
	rm -Rf "$pkgdir"/.omit
}

dev() {
	default_dev

	cd "$pkgdir"

	local path; for path in $(find $_ocamldir \( \
			-name '*.cmt' -o \
			-name '*.cmti' -o \
			-name '*.cmx' -o \
			-name '*.cmxa' -o \
			-name '*.ml' -o \
			-name '*.mli' \
		\))
	do
		amove "$path"
	done
}

sha512sums="
a3c9eb7df16912a1a8435a0379f1dca2ec5d287a452cf626c50d9c403db167f64a5a4360b0631a16536ca76cd0fa230bb883344227e028b48ee73264b34a000f  jackline-0.1.0.tar.gz
712de8f691e8573a80ac0a4cdf7f9cc9d61957cab58b7c7ed832e362807a1f80e075d3cfa6411e91198791b589336055b2ecd233dabe2d209bdb9a7287a9dd1e  use-built-in-uchar-lib.patch
049665823032ff23df2a2d8c1930a92ef29999d1d88a3d3fc121b7e255c53621189a1f5179b4133c1790077fc15a692e626ed967c2c2049553178879d176cd9b  latest-notty-compat.patch
"
